package com.java46.carera.position;

import com.java46.carera.base.entity.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class PositionController {
    @Autowired
    public PositionService positionService;

    // 添加
    @RequestMapping("/addPosition")
    public String addPosition(Integer staff_department, String position_name, String position_introduction){
        positionService.addPosition(staff_department,position_name,position_introduction);  // 获取页面上的值
        return "position/position";
    }

    // 删除
    @RequestMapping("/delPosition")
    public String delPosition(Integer position_id){
        positionService.delPosition(position_id);  // 获取页面上的值
        return "position/position";
    }

    // 修改前的查询
    @RequestMapping(value = "/selectPosition",  produces = "application/json;charset=utf-8")
    @ResponseBody
    public JsonResult  modifyDepartment(Integer position_id){
        JsonResult jsonResult = positionService.selectPosition(position_id);
        return jsonResult;
    }

    // 修改
    @RequestMapping("/uplPosition")
    public String uplPosition(Integer position_id, String position_name, String position_introduction, Integer staff_department){
        positionService.uplPosition(position_id, position_name, position_introduction, staff_department);  // 获取页面上的值
        return "position/position";
    }

    // 查询
    @RequestMapping("/selectPositionAll")
    @ResponseBody
    public JsonResult selectPositionAll(Integer pagenNum, String posName){
        JsonResult jsonResult = positionService.selectPositionAll(pagenNum, posName);
        return jsonResult;
    }

    // 查询
//    @RequestMapping("/selectPositionAllStaff")
//    @ResponseBody
//    public JsonResult selectPositionAllStaff(){
//        JsonResult jsonResult = positionService.selectPositionAllStaff();
//        return jsonResult;
//    }

    // 用于职位和员工的查询
    @RequestMapping("/selectDepPosition")
    @ResponseBody
    public JsonResult selectDepPosition(Integer department_id){
        JsonResult jsonResult = positionService.selectDepPosition(department_id);
        return jsonResult;
    }
}
